<?php include("../../includes/includes.php"); ?>
<?
connect($config);
$players = getPlayerReplacementNames();
$textDump = $_POST['textDump'];
$lines = preg_split("%\n%", $textDump);
$count = count($lines);
$round = getCurrentRound();
$team = "";
$mapKey = "";
for ($i = 0; $i < $count; $i++) {
	if (strpos($lines[$i], ":") == "") {
		$team = trim($lines[$i]);
		$mapKey = getAFLTeamMapKey($team);
	}
	else {
		$spaceIndex = strpos($lines[$i], " ");
		$linePosition = str_replace(":", "", trim(substr($lines[$i], 0, $spaceIndex)));
		$lineCells = split(", ", trim(substr($lines[$i], $spaceIndex)));
		$countLineCells = count($lineCells);
		for ($j = 0; $j < $countLineCells; $j++) {
        	processPlayer($lines[$j], $players, $mapKey, getPosition($linePosition, $j), $team, $round);
		}		
	}
}

mysql_close();

echo "</table><br><b>COMPLETED!!</b>";
?>